package com.bestcem.xm.user.grpc.service.param;

import com.alibaba.excel.annotation.ExcelProperty;
import com.bestcem.xm.common.core.constant.RegTypes;
import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.validator.constraints.Length;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Pattern;

/**
 * 开放平台的组织更新参数
 *
 * @author wangyunyun <yunyun.wang@idiaoyan.com>
 * @version v1.0
 * @date 2022/2/21 10:47
 */
@Getter
@Setter
public class GroupSyncParam {

    /**
     * 用户组组名称
     */
    @NotBlank(message = "4;group_list.name cannot be blank")
    @Length(max = 30, message = "7;group_list[name = {0}] length cannot be exceed 30")
    @Pattern(regexp = RegTypes.GROUP_NAME, message = "5;group_list.name 含有中英文、数字、下划线、中线以外的字符")
    @ExcelProperty(value = "name", index = 0)
    private String name;

    /**
     * 组编码
     */
    @NotBlank(message = "4;group_list.code cannot be blank")
    @Length(max = 30, message = "7;group_list[code = {0}] length cannot be exceed 30")
    @Pattern(regexp = RegTypes.GROUP_CODE, message = "5;group_list[code = {0}] 含有英文、数字、下划线、中线以外的字符")
    @ExcelProperty(value = "code", index = 1)
    private String code;

    /**
     * 层级名称
     */
    @NotBlank(message = "4;group_list.level_name cannot be blank")
    @Length(max = 30, message = "7;group_list[level_name = {0}] length cannot be exceed 30")
//    @Pattern(regexp = RegTypes.GROUP_LEVEL_NAME, dto = "5;group_list[level_name = {0}] 含有非法字符")
    @ExcelProperty(value = "level_name", index = 2)
    private String levelName;

    /**
     * 上级组织编码
     */
    @Length(max = 30, message = "7;group_list[parent_code = {0}] length cannot be exceed 30")
    @Pattern(regexp = RegTypes.GROUP_CODE, message = "5;group_list[parent_code = {0}] 含有英文、数字、下划线、中线以外的字符")
    @ExcelProperty(value = "parent_code", index = 3)
    private String parentCode;

    /**
     * 组负责人账号名
     */
    @Length(max = 128, message = "7;group_list[admin_name = {0}] length cannot be exceed 128")
    @ExcelProperty(value = "admin_name", index = 4)
    private String adminName;

    /**
     * 组负责人账号id
     */
    private String adminId;

    /**
     * 是否为根节点
     */
    @ExcelProperty(value = "root_flag", index = 5)
    private Boolean rootFlag;

    /**
     * 父组织的层级名称
     */
    @JsonIgnore
    private String parentLevelName;

}
